home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: netcom.com!andrewr
- From: andrewr@netcom.com (Andrew Reddig)
- Subject: Re: Borland C's tmpnam()
- Message-ID: <andrewrDp62z2.uw@netcom.com>
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- X-Newsreader: TIN [version 1.2 PL1]
- References: <AD75E5DC9668E2A52@mcdiala13.it.luc.edu> <Pine.A32.3.91.960322134158.23347A-100000@red.weeg.uiowa.edu> <AD78E5E796681EC58@mcdialb10.it.luc.edu> <827626790snz@genesis.demon.co.uk> <AD7CDFD39668AABD2@mcdiala01.it.luc.edu> <828276946snz@genesis.demon.co.uk> <AD84A73496681719A2@mcdiala03.it.luc.edu>
- Date: Mon, 1 Apr 1996 04:54:38 GMT
- Sender: andrewr@netcom13.netcom.com
-
- Verne Arase (VArase@varase.it.luc.edu) wrote:
- : In article <828276946snz@genesis.demon.co.uk>,
- : Lawrence Kirby <fred@genesis.demon.co.uk> wrote:
-
- : >>If you're stating that tmpnam() under Borland C does indeed check to see
- : >>that the file name is unique, I'll quash that reluctance and change the
- : >>default directory.
- : >
- : >I don't know what Borland C actually does. It it is a conforming
- : >implementation it must ensure that the name it generates is valid and
- : >doesn't already exist in the filesystem.
-
- : Actually, it doesn't.
-
- : All it does it insure that the file name doesn't exist in the current
- : location in the file system. Which, I'd imagine, is what just about every
- : implementation does.
-
- : It's be a lot more useful if you could specify a target directory, though
- : the string that makes up that specification would be target environment
- : dependant.
-
- I don't have the ANSI spec handy, but given that ANSI doesn't guarantee
- much about directories, drives, etc., it would seem logical that a
- conforming implementation is required to return whatever magic name is
- both (a) a valid filename and (b) not an existing file based on the
- current program context. Absent the race condition already discussed,
- what you need to do with the filename is open it - ANSI is pretty much
- silent on doing anything else with the filename, right? Once you open it,
- you can then change directories/drives/etc and the handle still points at
- a temporary file (which is what you want).
-
- So, Borland could return an 8.3 filename, "C:\TEMP\BORLAND.001", or
- whatever as long as you can open the file and not collide with an
- existing file. What you get by looking at the filename is undefined.
-
- If the standard is silent on where the temporary file is located, a
- conforming program couldn't change directories and assume that the file is
- put in that directory anyway; a conforming implementation could
- automagically put all temporary files in /tmp.
-
- --- Andy R. (andrewr@netcom.com)
-
- --
- --------------------------------------------------------------------
- Andrew Reddig #include "usual.disclaimer.h"
- TEK Microsystems, Incorporated Email: andyr@tekmicro.com
- One North Avenue Telephone: (617) 270-0808
- Burlington, MA 01803 Fax: (617) 270-0813
-